//
//  StackItemsView.m
//  PrivatePodspec
//
//  Created by YDY on 2024/11/27.
//

#import "StackItemsView.h"
#import "Masonry.h"

@interface StackItemsView ()

@property (nonatomic,strong) UIImageView *imageView;
@property (nonatomic,strong) UILabel *titleLabel;

@end

@implementation StackItemsView


- (instancetype)init
{
    self = [super init];
    if (self) {
        
        [self setBackgroundColor:UIColor.blueColor];
        [self addSubview:self.imageView];
        [self addSubview:self.titleLabel];
        
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.left.top.bottom.equalTo(self);
            make.width.height.mas_equalTo(40);
            
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.centerY.equalTo(self.mas_centerY);
            make.width.mas_equalTo(15);
            make.left.equalTo(self.imageView.mas_right);
            make.right.equalTo(self.mas_right);
        }];
    }
    return self;
}



- (void)setImage:(NSString *)image title:(NSString *)title {
    
    [self.imageView setImage:[UIImage imageNamed:image]];
    [self.titleLabel setText:title];
}

#pragma mark - lazy
- (UIImageView *)imageView {
    if (!_imageView) {
        
        _imageView = [[UIImageView alloc]init];
    }
    return _imageView;
}



-(UILabel *)titleLabel {
    if (!_titleLabel) {
        
        _titleLabel = [[UILabel alloc]init];
        [_titleLabel setTextColor:UIColor.blackColor];
    }
    return _titleLabel;
}


@end
